﻿open Rgr
open System
open System.IO


let sr = File.OpenText(@"1.txt");
let s = sr.ReadToEnd();
let ch = '\n';
let text = s.Split( ch);

let mutable point = new Point(-1,-1);
let mutable isFinded = 0;
let mutable scene = new Scene();

Seq.iteri(fun i x -> 
    String.iteri(fun y c -> 
        if c = '1'
        then
            point.X <- y;
            point.Y <- i;
            scene.AddPoint(point);      
    ) x
) text

let counter = ref 0;

Seq.iter(fun (f:Figure) ->
    if f.checkTriangle() && !counter < 4
    then 
        counter := !counter + 1;
        f.doCircle();
    if f.checkTriangle() && !counter = 4
    then 
        counter := !counter + 1;
        f.doCircle2();

    ) scene.Figures;
    

Seq.iteri(fun i x -> 
    String.iteri(fun y c -> 
        if c = '1' || c = '0'
         then
            point.X <- y;
            point.Y <- i;
            let test = scene.checkPoint(point);
            printf "%d" test;    
    ) x
    printfn "";
) text